package com.struts.web.corpor.register;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import com.base.Constants;
import com.lg.system.CLGAction;
import com.struts.deal.corpor.register.Deal;

public class CorporDetailAction extends CLGAction {
     
	
	public ActionForward execute(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws
Exception {
		boolean result = false;
		ActionMessages msgs = new ActionMessages();
		CorporDetailForm aWebForm = (CorporDetailForm)actionForm;
		
		if(aWebForm.getMethod()!=null && aWebForm.getMethod().equals("add")){
			logger.info("adddetail");
			result=Deal.addDetail(request, response, aWebForm);
			if(result==true){
				return actionMapping.findForward("regFinish");
			}else{
				msgs.add("commonMsgs",new ActionMessage(Constants.ADDMER_FAIL_KEY));
				saveErrors(request,msgs);
			    return actionMapping.findForward("fail");
			}
		}else{
			logger.info("load:"+aWebForm.getMethod());
			Deal.loadDetail(request, response, aWebForm);
			return actionMapping.getInputForward();
		}
		
}
	
	
}
